package cn.edu.nit.sys.controller;

import cn.edu.nit.sys.entity.Leave;
import cn.edu.nit.sys.service.LeaveService;
import cn.edu.nit.sys.utils.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author xiaobai
 * @Date 2023/3/19 19:29
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/leave")
public class LeaveController {

    @Autowired
    private LeaveService leaveService;

    @PostMapping
    public R addLeave(@RequestBody Leave leave) {
        return leaveService.addLeave(leave);
    }

    @GetMapping("/{uid}")
    public R getLeaveList(Page<Leave> page, @PathVariable("uid") String uid) {
        return leaveService.getLeaveList(page, uid);
    }

    @GetMapping("/detail/{id}")
    public R getLeaveDetail(@PathVariable("id") String id) {
        return leaveService.getDetail(id);
    }
}
